<?php

namespace app\controllers\admin\uni\system;

use app\controllers\admin\base\AdminController;
use app\models\system\SetQrcode as Model;

class QrcodeController extends AdminController
{
    public function actionFetch()
    {
        $model = Model::getLastOne();

        return $this->success($model);
    }

    public function actionSave()
    {
        $text = $this->post('text');
        $images = $this->post('image');

        $data = $this->post();

        if (Model::saveData($text, $images, $data)) {

            // 保存其它属性
            // $model = Model::getLastOne();
            // $model->width = $data['width'];
            // $model->height = $data['height'];
            // $model->left = $data['left'];
            // $model->top = $data['top'];
            // $model->save();
            // var_dump($model->getFirstErrors());exit;

            return $this->success();
        }

        return $this->fail();
    }

}